//
//  ZCStatusToolsView.m
//  百思不得姐
//
//  Created by Ning Xie on 16/8/28.
//  Copyright © 2016年 zhangchong. All rights reserved.
//

#import "ZCStatusToolsView.h"
#import "ZCEssenceModel.h"
#import "ZCVerticalButton.h"


typedef enum : NSUInteger {
    dingButton = 0,
    hateButton = 1,
    repostButton = 2,
    commentButton = 3
} StatusToolButtonType;

@interface ZCStatusToolsView ()

@property (strong,nonatomic) NSMutableArray<UIButton *> *buttonArray;
@end

@implementation ZCStatusToolsView


-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}
-(void)setupUI{
    
    self.backgroundColor = ZCGlobalRBG;
    CGFloat width = ([UIScreen mainScreen].bounds.size.width -23)/4;
    
    CGFloat height = 35;
    for (NSInteger i = 0; i<4; i++)
    {
        UIButton *button = [UIButton buttonWithImage:[NSString stringWithFormat:@"mainCell0%ld",i+1] diabledImage:[NSString stringWithFormat:@"mainCell0%ldClick",i+1] fontSize:12 textColor:[UIColor grayColor] diabledTextColr:[UIColor redColor]];
        button.backgroundColor = [UIColor whiteColor];
        button.frame = CGRectMake(i*(width+1)+10, 1, width, height);
        button.tag = i;
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        [self.buttonArray addObject:button];
        [self addSubview:button];
    }
}

-(void)setModel:(ZCEssenceModel *)model{
    _model = model;
    
    [self.buttonArray[0] setTitle:model.ding forState:UIControlStateNormal];
    [self.buttonArray[1] setTitle:model.cai forState:UIControlStateNormal];
    [self.buttonArray[2] setTitle:model.repost forState:UIControlStateNormal];
    [self.buttonArray[3] setTitle:model.comment forState:UIControlStateNormal];
    
}
-(void)buttonAction:(UIButton*)sender{
    
    if (sender.tag == dingButton) {
        ZCLog(@"我顶");
        sender.enabled = NO;
        self.buttonArray[1].userInteractionEnabled = NO;
    }else if (sender.tag == hateButton){
        ZCLog(@"我踩");
        sender.enabled = NO;
        self.buttonArray[0].userInteractionEnabled = NO;
    }else if (sender.tag == repostButton){
        ZCLog(@"转发");
    }else{
        ZCLog(@"评论");
        
    }
}
-(NSMutableArray<UIButton *> *)buttonArray{
    if (_buttonArray == nil) {
        _buttonArray = [NSMutableArray array];
    }
    return _buttonArray;
}
@end
